<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>函数的应用</title>
</head>
<body>

</body>
<script>
  /**
   *  函数的应用
   *    1. 数组的非变异操作
   *        filter
   *        find
   *        map
   *        reduce
   *
   *    2. 异步函数
   * */


    /**
     *  1) 单值数组操作
     * **/

  var arr = [1,3,5,7];

  var arr2= arr.filter(function (num){
     return num>3;
  })

  console.log(arr);
  console.log(arr2);

  var num = arr.find(function (item){
    return item==3;
  })

  var  num2 = arr.find(function (item){
    return item==11;
  })

  var  num3 = arr.find(function (item){
    return item>3;
  })

  console.log(num);
  console.log(num2);

  console.log(num3)


  var arr3= arr.map(function (item){
     return item*item;
  })

 var total=  arr.reduce(function (prev,curr){
      return prev + curr;
  })


  console.log(arr3);



</script>
</html>